# Contributor: Sergei Lukin <sergej.lukin@gmail.com>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libsndfile
pkgver=1.0.28
pkgrel=8
pkgdesc="A C library for reading and writing files containing sampled sound"
url="http://www.mega-nerd.com/libsndfile"
arch="all"
license="LGPL-2.0-or-later"
subpackages="$pkgname-dev $pkgname-doc"
depends=
depends_dev="flac-dev libvorbis-dev libogg-dev"
makedepends="linux-headers alsa-lib-dev $depends_dev"
source="http://www.mega-nerd.com/$pkgname/files/$pkgname-$pkgver.tar.gz
	CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch
	CVE-2017-8362.patch
	CVE-2017-12562.patch
	CVE-2018-13139.patch
	CVE-2017-17456_CVE-2017-17457_CVE-2018-19661_CVE-2018-19662.patch
	CVE-2018-19758.patch
	fix-rf64-varargs-bug.patch
	"
# sporadic testsuite failures on armhf
case $CARCH in arm*) options="!check";; esac

# secfixes:
#   1.0.28-r8:
#     - CVE-2018-19758
#     - CVE-2019-3832
#   1.0.28-r7:
#     - CVE-2018-19758
#   1.0.28-r6:
#     - CVE-2017-17456
#     - CVE-2017-17457
#     - CVE-2018-19661
#     - CVE-2018-19662
#   1.0.28-r4:
#     - CVE-2018-13139
#   1.0.28-r2:
#     - CVE-2017-12562
#   1.0.28-r0:
#     - CVE-2017-7585
#     - CVE-2017-7741
#     - CVE-2017-7742
#   1.0.28-r1:
#     - CVE-2017-8361
#     - CVE-2017-8362
#     - CVE-2017-8363
#     - CVE-2017-8365

build() {
	cd "$builddir"
	ac_cv_sys_largefile_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-sqlite \
		--enable-largefile
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}
sha512sums="890731a6b8173f714155ce05eaf6d991b31632c8ab207fbae860968861a107552df26fcf85602df2e7f65502c7256c1b41735e1122485a3a07ddb580aa83b57f  libsndfile-1.0.28.tar.gz
f98c40696fca3e7bca867df993de55bb4145c23428e65d1a669182eb2293046478ac727ae7f94bb77123ef0355c3c53be4f9d6a432665c90c74687d8d3afd9e3  CVE-2017-8361_CVE-2017-8363_CVE-2017-8365.patch
dfd4b5f1c7471fc416eed5c6040580a020543f145de9103751adaad6ce1c5c6a22abc1cf0ffd381aed3072644cd5ee03ba3598265aa7d202d63167da251cb595  CVE-2017-8362.patch
814139567d90fb07908014e858c341fe933e04dca69b88ad66078910888237bbeba94f85d9e1489883c424f35fca312eb98c21ae2b122d9289bb6418725cd02e  CVE-2017-12562.patch
33817e7c85180635fa239e4ea38973b18312878522639f43071188a995f0e1a35dbca6d133555fb0875292b4b609950ae38e747a6b1949f8ae840db9dc3a2805  CVE-2018-13139.patch
ba3e5321713dbc118f45dac6f86049a15e6ba54fc788776eb267b1b165a0853bec278d8b066c71372cd243c852faa6781bef6a71d108e7cdbc64fb77fa3afc0a  CVE-2017-17456_CVE-2017-17457_CVE-2018-19661_CVE-2018-19662.patch
ec90d652056166188ccc360d463d7b5549510aca7fcbbb439dd2d6086f759236ece6091c76d0c7074fb09e7b86df229c39ffdd8c8603b253c33d4d05c42615d2  CVE-2018-19758.patch
0b7ce6bd6c1ec825521974c36b8c6eb5edd17d3c57d5ae3de287fb34a6be7108bc9511abb497538eef36e5883b84f4137fad6fe9a1d150345111de9f068838f9  fix-rf64-varargs-bug.patch"
